//
//  SISSContactListCell.m
//  SISSAPP
//
//  Created by 优房网 on 2017/3/15.
//  Copyright © 2017年 优房网. All rights reserved.
//

#import "SISSContactListCell.h"
#import <SDWebImage/UIImageView+WebCache.h>

@interface SISSContactListCell ()
@property (weak, nonatomic) IBOutlet UIImageView *iconImageView;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *latestTimeLabel;
@property (weak, nonatomic) IBOutlet UILabel *latestMessageLabel;
@property (weak, nonatomic) IBOutlet UIButton *redBadgeButton;

@end
@implementation SISSContactListCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setContactModel:(SISSContactModel *)contactModel {
    _contactModel = contactModel;
    
    [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:contactModel.portrait] placeholderImage:[UIImage imageNamed:@"头像"]];
    self.nameLabel.text = contactModel.name;
    self.latestTimeLabel.text = contactModel.latestTimeStr;
    self.latestMessageLabel.text = contactModel.latestMessageStr;
    
    [self.redBadgeButton setTitle:[NSString stringWithFormat:@"%zd",contactModel.unreadCount] forState:UIControlStateNormal];
    self.redBadgeButton.hidden = !contactModel.unreadCount;
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
